<?php
echo '<script charset="utf-8" type="text/javascript" src="_response/bin.php?get=../../Modules/Operative/client.js"></script>';

	MYTCONN();
	// Vars
	if (isset($_POST['OBCJ'])) {
	$panel['name'] = $_POST['OBCJ'];
	$SearchParam = $_POST['SearchParam'];
	$SearchValue = $_POST['SearchValue'];
	} else {
	$panel['name'] = $_GET['OBJ'];
	$SearchParam = $_GET['SearchParam'];
	$SearchValue = $_GET['SearchValue'];
	}

	$OB_SELEC = 'CLIENTE';

	$DBGET = $GLOBALS['MYT']->db_array("SELECT CliNumero AS O_ID, CliNombre AS COL1, CliTelefono AS COL4, CliTelefono2 COL2, CliDomicilio AS COL3, pai_NombreESP AS COL5, ClObs AS COL6, CliProfile
  			FROM clientes
  				LEFT OUTER JOIN hd_paises ON pai_CodElite = ClPais
			WHERE CliProfile > 0
			AND CliNombre = (SELECT CliNombre FROM clientes WHERE {$SearchParam} = {$SearchValue})");
	$CARD = $DBGET[0];
	$SUM = 0;

	form_pr('form_cldup','','','post');
	mn_field('hidden','ED','sel_CL','','','','','');
	mn_field('hidden','ED','mgr_CL','','','','','');
	echo '<div id="resultsList"></div>';

	echo '<div style="height:200px;overflow:auto"><table width="120%">
<tr style="height:28px">
    <td>Manter</td>
    <td>Apagar</td>
    <td></td>
	<td>Numero</td>
	<td>Nome</td>
	<td>Telefone</td>
	<td>Telemovel</td>
	<td>Morada</td>
	<td>Pais</td>
	<td>Observacao</td>
	</tr>';

	for ($i=1;$i<=$CARD;$i++) {
	$a = $i-1;
	$SUM = $SUM+$DBGET[$i]['COL4'];
	echo "<tr style=\"height:28px\" bgcolor=\"".gridlines($i)."\"><td align=\"center\">";
		mn_field('checkbox','ED','tmp_mntcheck',$DBGET[$i]['O_ID'],'','','','" onclick="mnt_checker('.$a.');');
			echo "</td><td align=\"center\">";
		mn_field('checkbox','ED','tmp_mgrcheck',$DBGET[$i]['O_ID'],'','','','" onclick="migr_checker('.$a.');');
			echo "</td><td>";
		mn_field('button','ED','tmp_view','Detalhe','','','','" onclick="open_view('.$DBGET[$i]['O_ID'].')');
			echo "</td>
					<td NOWRAP>{$DBGET[$i]['O_ID']}</td>
					<td>{$DBGET[$i]['COL1']}</td>
					<td>{$DBGET[$i]['COL2']}</td>
					<td NOWRAP>{$DBGET[$i]['COL4']}</td>
					<td>{$DBGET[$i]['COL3']}</td>
					<td NOWRAP>{$DBGET[$i]['COL5']}</td>
	<td>{$DBGET[$i]['COL6']}</td></tr>";
    }
echo '</table>

	</div> Possiveis repetições # '.$CARD.' | ';
	if ($CARD > 1) {
		mn_field('button','ED','do_submit','Juntar Clientes','','','','SUBMIT" onclick="this.disabled=\'true\';migr_submit();');
	} else {
		echo 'Nao existem duplicacoes para este cliente.';
	}
	echo '<div id="do_clientmigr"></div></form>'; ?>